﻿Imports System.Data.Linq

Namespace DatabaseStorageDemo.Model
   Public Class FileStorageDataContext
      Inherits DataContext
      Public Sub New(connectionString As String)

         MyBase.New(connectionString)
      End Sub

      ''' <summary>
      ''' Gets the files table.
      ''' </summary>
      ''' <value>The files table.</value>
      Public ReadOnly Property Files() As Table(Of DatabaseFile)
         Get
            Return GetTable(Of DatabaseFile)()
         End Get
      End Property

      ''' <summary>
      ''' Saves the specified new file.
      ''' </summary>
      ''' <param name="newFile">The new file.</param>
      Public Sub Save(newFile As DatabaseFile)
         If newFile Is Nothing Then
            Throw New ArgumentNullException("newFile")
         End If

         Files.InsertOnSubmit(newFile)
         SubmitChanges()
      End Sub
   End Class
End Namespace
